
<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <div class="col-md-12">
        <form method="get" class="  form-horizontal " action="{:url('ajaxproduct')}">
            <div class="form-group">
            <div class="col-md-6">
                <input type="text" class="form-control " name="keyword" placeholder="请输入物料名称" value="{$keyword}" >
                <input type="submit" class="  btn btn-primary" value="搜索">
            </div>
            </div>
        </form>
    </div>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="16">
                    <label>
                        <input type="checkbox" class=" js-check-all data-item-tr" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th>ID</th>
                <th>产品编号</th>
                <th>产品名称</th>
                <th>单价</th>
                <th>单位</th>
                <th>所属库房</th>
                <th>剩余库存</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="result" item="vo">
                <tr>
                    <td class="text-left">
                        <input type="checkbox" class="js-check "
                               data-goods_num="{$vo.goods_num}"
                               data-goods_id="{$vo.goods_id}"
                               data-goods_name="{$vo.goods_name}"
                               data-price="{$vo.price}"
                               data-price_unit="{$vo.price_unit}"
                               data-room_name="{$vo.room_name}"
                               data-stock="{$vo.stock}"
                               value="{$vo.id}"/>
                    </td>
                    <td>{$vo.id}</td>
                    <td>{$vo.goods_num}</td>
                    <td>{$vo.goods_name}</td>
                    <td>{$vo.price}</td>
                    <td>{$vo.price_unit}</td>
                    <td>{$vo.room_name}</td>
                    <td>{$vo.stock}</td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
</div>
<script src="__STATIC__/js/admin.js?v={:time()}"></script>
<script>
    $('.data-item-tr').click(function (e) {
        var name = $(".js-check");
        for(var i=0;i<name.length;i++){
            if(name[i].checked)
                name[i].checked=false ;
            else
                name[i].checked=true ;
        }
    });

    function confirm() {
        var selectedId   = [];
        var selectedGoodsName = [];
        var productList     = [];
        $('.js-check:checked').each(function () {
            var $this = $(this);
            selectedId.push($this.val());
            selectedGoodsName.push($this.data('goods_name'));
            productList.push({
                id: $this.val(),
                goods_num: $this.data('goods_num'),
                goods_id: $this.data('goods_id'),
                goods_name: $this.data('goods_name'),
                price: $this.data('price'),
                price_unit: $this.data('price_unit'),
                room_name: $this.data('room_name'),
                stock: $this.data('stock'),
            });
        });
        return {
            productList: productList,
            goodsId: selectedId,
            goodsName: selectedGoodsName
        };
    }
</script>

</div>
</body>
</html>





